home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000037_icon-group-sender _Tue May 26 12:41:06 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id MAA27062
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 26 May 1998 12:41:06 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA01479; Tue, 26 May 1998 12:41:00 -0700
  7. Date: Mon, 25 May 1998 08:18:17 -0700
  8. From: Ralph Griswold <ralph>
  9. Message-Id: <9805251518.AA02290@jupiter.CS.Arizona.EDU>
  10. To: icon-group
  11. Subject: forwarded message
  12. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  13. Status: RO
  14. Content-Length: 2300
  15.  
  16. From: "Paul A. Sue" <Paul_A._Sue@notes.bctel.com>
  17. To: icon-project@optima.CS.Arizona.EDU
  18. Message-Id: <0825660C.006C0CCA.00@notes.bctel.com>
  19. Date: Fri, 22 May 1998 11:48:10 -0800
  20. Subject: Help Me Promote Icon!
  21. Mime-Version: 1.0
  22. Content-Type: text/plain; charset=us-ascii
  23. Status: RO
  24.  
  25. Hi,
  26.  
  27. [Sorry to bother you, but no one seems to be responding to
  28. me post to comp.lang.icon.]
  29.  
  30. I'm a very recent convert to Icon, and thought I'd use it here at work
  31. to write a simple translator that I had originally written in C and Perl.
  32. I wanted to show that Icon would be an ideal language for many
  33. of the projects at my company.
  34.  
  35. Anyhow, here's the Perl script along with sample input and output
  36. to give you an idea of what I'm trying to do.
  37.  
  38. Thanks in advance,
  39.  
  40. Paul
  41. =================================================
  42. Paul A. Sue, Consultant              ISM-BC AD/M
  43. Voice-mail: (604) 432-4316 Pager: (604) 473-2811
  44. E-mail:  paul@wsi.ca or paul_sue@notes.bctel.com
  45.  
  46. [From comp.lang.icon]
  47.  
  48. --------------------- Start of included file ----------------------------
  49. From: Paul A. Sue <paul_sue@notes.bctel.com>
  50. Subject: Newbie question
  51. Date: Thursday, May 14, 1998 1:46 PM
  52.  
  53. Hi,
  54.  
  55. I'm wondering if anyone can help me "translate" the following Perl
  56. script to the Icon equivalent.
  57.  
  58. [Perl gurus feel free to improve on my perl script if you wish!]
  59.  
  60. Thanks in advance,
  61.  
  62. Paul
  63.  
  64. #!/usr/local/bin/perl
  65. while (<>) {
  66.      chomp;
  67.      if (/[a-z]/) {
  68.       # --- convert from Directory to M/F format
  69.           s#$#//#;
  70.           s#^([a-z])#\*\1#;
  71.           s#(\s+)([a-z])# \*\2#g;
  72.           s#([a-z]+)([A-Z]+)#\1\(\2\)#g;
  73.           tr/a-z/A-Z/;
  74.           @result = split;
  75.           $index = $#result;
  76.           if ($index > 0) {
  77.                $result[$index - 1] .= ",";
  78.           }
  79.      }
  80.      else {
  81.       # --- convert from M/F to Directory format
  82.           s#//$##;
  83.           s#,##g;
  84.           tr/A-Z/a-z/;
  85.           s#(\()(.*)(\))#\U\2#g;
  86.           s#(^([a-z])|(\s+[a-z]))#\U\1\E#g;
  87.           s#\*##g;
  88.           @result = split;
  89.      }
  90.  print "@result\n";
  91.  next;
  92. }
  93.  
  94. Sample input/output:
  95.  
  96. input of:    "MacDonald John"
  97. gives output of:     "MAC(D)ONALD, JOHN//"
  98. input of:     "*VAN *DER(C)ORTLAND, NICK//"
  99. gives output of:     "van derCortland Nick"
  100. --------------------- End of included file ----------------------------
  101.  
  102.  
  103.  
  104.  
  105.